package ch.exm.storm.conditions;


public class Or extends AbstractCompositeCondition {

	public Or(Condition... conditions) {
		super(conditions);
	}

	public Or(Iterable<Condition> conditions) {
		super(conditions);
	}

	public boolean matches(Object object) {
		for (Condition condition : conditions) if (condition.matches(object)) return true;
		return false;
	}

	@Override
	public Or addCondition(Condition condition) {
		return or(condition);
	}
	
	@Override
	protected String getConditionKeyword() {
		return " or ";
	}
	
	@Override
	protected boolean isShortcutCondition() {
		return true;
	}


	@Override
	public Or or(Condition condition) {
		if (condition instanceof Or) for (Condition c : (Or)condition) addCondition(c);
		else super.addCondition(condition);
		return this;
	}
}
